package cn.panda.edu.service.impl;

import cn.panda.edu.dao.ScoreMapper;
import cn.panda.edu.model.Score;
import cn.panda.edu.service.ScoreService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 
 * 类描述： 成绩表的实现层  
 * @author: 张坤鹏  
 * @date： 2018-01-16 下午12:12:42
 */
@Service
public class ScoreServiceImpl implements ScoreService {
	
	@Autowired
	private ScoreMapper scoreMapper;
	@Override
	public PageInfo<Score> listScoreByPage(Integer stuId, Integer pageIndex, Integer pageSize) {
		// TODO Auto-generated method stub
		PageHelper.startPage(pageIndex,pageSize);
		List<Score> list = scoreMapper.listScoreByStuId(stuId);
		PageInfo<Score> pageInfo = new PageInfo<>(list);
		return pageInfo;
	}

	@Override
	public void saveScore(Score score) {
		// TODO Auto-generated method stub
		scoreMapper.insertSelective(score);
	}
	/**
	 * 显示所有成绩信息
	 */
	@Override
	public PageInfo<Score> getAllListScore(Integer pageIndex,Integer pageSize,Integer id,String name) {
		// TODO Auto-generated method stub
		PageHelper.startPage(pageIndex,pageSize);
		List<Score> list= scoreMapper.getAllListScore(id,name);
		PageInfo<Score> pageInfo=new PageInfo<>(list);
		return pageInfo;
	}
	/**
	 * 修改成绩信息
	 */
	@Override
	public int updateByPrimaryKeySelective(Score record) {
		return scoreMapper.updateByPrimaryKeySelective(record);
	}
	
	/**
	 * 动态添加成绩数据
	 */
	@Override
	public int insertSelective(Score record) {
		// TODO Auto-generated method stub
		return scoreMapper.insertSelective(record);
	}
	
}
